<?php
require('config.php');
	$user_id=$_REQUEST['user_id'];
	$xiaoxi_id=$_REQUEST['xiaoxi_id'];
	$sql="SELECT * FROM ".$oto."_help_message where id='$xiaoxi_id' and userId='$user_id'";
	$result=$db->query($sql);
	while($row=$result->fetch_assoc()){
		$message[]=$row;//将取得的所有数据赋值给person_info数组
	}
	if(isset($message))
	{
		$helpId=$message[0]['helpId'];
		$sql="SELECT id FROM ".$oto."_help_orders where helpId='{$helpId}' and acceptUserId='{$user_id}'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$orders[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($orders))
		{
			$data[0]['pan']="false";
			$data[0]['msg']="删除失败：订单已生成，您可以取消订单或申请退款";
		}
		else
		{
			$sql="UPDATE ".$oto."_help_message SET `isDel`='1' where id='{$xiaoxi_id}' and userId='{$user_id}' and msg_type in ('0','2')";
			$result=$db->query($sql);
			if($result)
			{
				$data[0]['pan']="true";
				$data[0]['msg']="删除成功";
			}
			else
			{
				$data[0]['pan']="false";
				$data[0]['msg']="删除失败";
			} 
			$sql="UPDATE ".$oto."_help_order_user SET `isDel`='1' where help_id='{$helpId}' and user_id='{$user_id}'";
			$result=$db->query($sql);
		}
	}
	else 
	{
		$data[0]['pan']="false";
		$data[0]['msg']="消息不存在";
	}
	echo json_encode($data);
?>